home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / CEGUISDK-0.4.1-VC6-STLport.exe / {app} / Samples / common / include / CEGuiD3D81BaseApplication.h < prev    next >
C/C++ Source or Header  |  2005-11-25  |  3KB  |  122 lines

  1. /************************************************************************
  2.     filename:   CEGuiD3D81BaseApplication.h
  3.     created:    24/9/2004
  4.     author:     Paul D Turner
  5. *************************************************************************/
  6. /*************************************************************************
  7.     Crazy Eddie's GUI System (http://www.cegui.org.uk)
  8.     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
  9.  
  10.     This library is free software; you can redistribute it and/or
  11.     modify it under the terms of the GNU Lesser General Public
  12.     License as published by the Free Software Foundation; either
  13.     version 2.1 of the License, or (at your option) any later version.
  14.  
  15.     This library is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.     Lesser General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU Lesser General Public
  21.     License along with this library; if not, write to the Free Software
  22.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23. *************************************************************************/
  24. #ifndef _CEGuiD3D81BaseApplication_h_
  25. #define _CEGuiD3D81BaseApplication_h_
  26.  
  27. #include "CEGuiBaseApplication.h"
  28.  
  29. #if defined( __WIN32__ ) || defined( _WIN32 )
  30. #   define WIN32_LEAN_AND_MEAN
  31. #   include <windows.h>
  32.  
  33. // undefine Microsoft macro evilness
  34. #   undef min
  35. #   undef max
  36. #endif
  37.  
  38. #if defined(_WIN32)
  39. #  pragma comment(lib, "d3d8.lib")
  40. #  if defined(_DEBUG)
  41. #      pragma comment(lib, "DirectX81GUIRenderer_d.lib")
  42. #  else
  43. #      pragma comment(lib, "DirectX81GUIRenderer.lib")
  44. #  endif
  45. #endif
  46.  
  47.  
  48. struct CEGuiD3D81BaseApplicationImpl;
  49.  
  50.  
  51. class CEGuiD3D81BaseApplication : public CEGuiBaseApplication
  52. {
  53. public:
  54.     /*!
  55.     \brief
  56.         Constructor.
  57.     */
  58.     CEGuiD3D81BaseApplication();
  59.  
  60.  
  61.     /*!
  62.     \brief
  63.         Destructor.
  64.     */
  65.     ~CEGuiD3D81BaseApplication();
  66.  
  67.  
  68.     // Implementation of base class abstract methods.
  69.     bool execute(CEGuiSample* sampleApp);
  70.     void cleanup();
  71.  
  72.  
  73. protected:
  74.     /*************************************************************************
  75.         Implementation methods
  76.     *************************************************************************/
  77.     /*!
  78.     \brief
  79.         Initialise Direct3D system.
  80.     */
  81.     bool initialiseDirect3D(unsigned int width, unsigned int height, unsigned int adapter, bool windowed);
  82.  
  83.     /*!
  84.     \brief
  85.         Do reset of Direct3D device
  86.  
  87.     \return
  88.         - true if the device was reset successfully
  89.         - false if the device was not reset.
  90.     */
  91.     bool resetDirect3D(void);
  92.  
  93.  
  94.     void updateFPS(void)
  95.     {
  96.         ++d_frames;
  97.  
  98.         DWORD thisTime = GetTickCount();
  99.  
  100.         if (thisTime - d_lastTime >= 1000)
  101.         {
  102.             d_FPS = d_frames;
  103.             d_frames = 0;
  104.             d_lastTime = thisTime;
  105.         }
  106.  
  107.     }
  108.  
  109.  
  110.     /*************************************************************************
  111.         Data fields
  112.     *************************************************************************/
  113.     CEGuiD3D81BaseApplicationImpl* pimpl;
  114.  
  115.     // FPS stuff
  116.     DWORD   d_lastTime;
  117.     int d_frames;
  118.     int d_FPS;
  119. };
  120.  
  121. #endif  // end of guard _CEGuiD3D81BaseApplication_h_
  122.